<template>
  <div>
    <el-dialog title="新闻信息" :visible.sync="dialogFormVisible"  :loading="loading" width="800px">
      <el-form :model="news">
        <el-form-item label="新闻编号" :label-width="formLabelWidth" prop='newsId'>
          <el-input v-model="news.newsId" autocomplete="off" :readonly="readonly"></el-input>
        </el-form-item>
        <el-form-item label="学部编号" :label-width="formLabelWidth" prop='newsPartId'>
          <el-input v-model="news.newsPartId" autocomplete="off" :readonly="readonly"></el-input>
        </el-form-item>
        <el-form-item label="新闻标题" :label-width="formLabelWidth" prop='newsTitle'>
          <el-input v-model="news.newsTitle" autocomplete="off" :readonly="readonly"></el-input>
        </el-form-item>
        <el-form-item label="新闻作者" :label-width="formLabelWidth" prop='newsAuthor'>
          <el-input v-model="news.newsAuthor" autocomplete="off" :readonly="readonly"></el-input>
        </el-form-item>
        <el-form-item label="新闻内容" :label-width="formLabelWidth" prop='newsContent"'>
          <el-input v-model="news.newsContent" autocomplete="off" :readonly="readonly" type="textarea" rows="5"></el-input>
        </el-form-item>
        <el-form-item label="新闻类别" :label-width="formLabelWidth" prop='newsType'>
          <el-input v-if="news.newsType=='1'" value="学部新闻" autocomplete="off" :readonly="readonly"></el-input>
          <el-input v-if="news.newsType=='2'" value="校级新闻" autocomplete="off" :readonly="readonly"></el-input>
        </el-form-item>
        <el-form-item label="新闻状态" :label-width="formLabelWidth" prop='newsStatus'>
          <el-input v-if="news.newsStatus=='0'" value="不可见" autocomplete="off" :readonly="readonly"></el-input>
          <el-input v-if="news.newsStatus=='1'" value="可见" autocomplete="off" :readonly="readonly"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">关 闭</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import {
    getNewsByNewsId
  } from '../../api/news.js'
  export default {
    components: 'Info',
    name: 'Info',
    props: {
      newsId: String,
      show: {
        default: false,
        require: true
      }
    },
    data() {
      return {
        news: {},
        loading: false,
        dialogFormVisible: false,
        formLabelWidth: '150px',
        title: '查看新闻信息',
        readonly: true,
      }

    },
    create() {

    },
    methods: {

      showInfo(newsId) {
        console.log(newsId)
        this.title = "查看新闻信息"
        this.readonly = true
        this.fetchData(newsId)
      },
      fetchData(newsId) {
        console.log(newsId)
        this.loading = true
        getNewsByNewsId(newsId).then((data) => {
          this.news = data.obj
          console.log(data)
          console.log(this.news)
          this.loading = false
          this.dialogFormVisible = true
        })
      },
    },
    watch: {}

  }
</script>

<style scoped>

</style>
